package com.dhkj.circle.utils;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 日期管理工具类
 */
public class DateUtils {

    public static String getFKRQ() {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
        String dateNowStr = sdf.format(d);
        return dateNowStr;
    }

    public static String getNow() {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateNowStr = sdf.format(d);
        return dateNowStr;
    }
    public static String getNOW_y1() {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateNowStr = sdf.format(d);
        return dateNowStr;
    }
    public static int getWeekNum() {
        int int_rs = 0;
        Date date = new Date();
        SimpleDateFormat dateFm = new SimpleDateFormat("EEEEE");
        String currSun = dateFm.format(date);
        int_rs = Integer.parseInt(currSun);
        return int_rs;
    }



//    public static String getResDate() {
//        Date date = new Date();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//        if ("1".equals(Const.getMDay())) {
//            Calendar calendar = new GregorianCalendar();
//            calendar.setTime(date);
//            calendar.add(calendar.DATE, 1); //把日期往后增加一天,整数  往后推,负数往前移动
//            date = calendar.getTime(); //这个时间就是日期往后推一天的结果
//        }
//        return sdf.format(date);
//    }


//
//
//    public static String getResDateDCRQ() {
//        Date date = new Date();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00:000");
//        if ("1".equals(Const.getMDay())) {
//            Calendar calendar = new GregorianCalendar();
//            calendar.setTime(date);
//            calendar.add(calendar.DATE, 1); //把日期往后增加一天,整数  往后推,负数往前移动
//            date = calendar.getTime(); //这个时间就是日期往后推一天的结果
//        }
//        return sdf.format(date);
//    }




    public static void main(String[] args) {
//        String str = "1234";
//        String a = "{\"code\":0,\"message\":\"请求成功！\",\"result_code\":\"FAIL\",\"info\":\"appid=wx9dc5d0afd4714838\\u003cbr\\u003eerr_code=ORDERNOTEXIST\\u003cbr\\u003eerr_code_des=订单不存在\\u003cbr\\u003emch_id=1532086821\\u003cbr\\u003enonce_str=MG68piZQHmNoCE6b\\u003cbr\\u003eresult_code=FAIL\\u003cbr\\u003ereturn_code=SUCCESS\\u003cbr\\u003ereturn_msg=OK\\u003cbr\\u003esign=F609B325438E3AC7239EA07DEAAD9F27\\u003cbr\\u003e\"}";
//        try {
//            System.out.println(new String(a.getBytes(), "utf-8"));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//        String url = "http://172.12.1.123/test.txt";
//        String regex = "(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})";
//        //        String regex = "(\\d{1,3}\\.){1,3}(\\d{1,3})";
//        System.out.println(getMatcher(regex, url));
//        for (String goo : getStrings("https://wenku.baidu.com/view/e109601f52d380eb62946d75.html?rec_flag=default&mark_pay_doc=2&mark_rec_page=1&mark_rec_position=4&mark_rec=view_r_1&clear_uda_param=1")) {
//            System.out.println(goo);
//        }
//
//
//        String str2 = "appid=wx9dc5d0afd4714838\\u003cbr\\u003eattach=\\u003cbr\\u003ebank_type=CFT\\u003cbr\\u003ecash_fee=15\\u003cbr\\u003efee_type=CNY\\u003cbr\\u003eis_subscribe=Y\\u003cbr\\u003emch_id=1532086821\\u003cbr\\u003enonce_str=3DLZ7Og37r8SJDTO\\u003cbr\\u003eopenid=olNvTvq3TVq8QLWA4wRVdVxS9Mi4\\u003cbr\\u003eout_trade_no=WXZFC2019051614461685801\\u003cbr\\u003eresult_code=SUCCESS\\u003cbr\\u003ereturn_code=SUCCESS\\u003cbr\\u003ereturn_msg=OK\\u003cbr\\u003esign=23FB763DCC9A5692029F1B20B88CBE01\\u003cbr\\u003etime_end=20190516144631\\u003cbr\\u003etotal_fee=15\\u003cbr\\u003etrade_state=SUCCESS\\u003cbr\\u003etrade_state_desc=支付成功\\u003cbr\\u003etrade_type=MICROPAY\\u003cbr\\u003etransaction_id=4200000333201905168104579300\\u003cbr\\u003e";
//        String str3 = "appid=wx9dc5d0afd4714838\\u003cbr\\u003eattach=\\u003cbr\\u003ebank_type=CFT\\u003cbr\\u003ecash_fee=15\\u003cbr\\u003efee_type=CNY\\u003cbr\\u003eis_subscribe=Y\\u003cbr\\u003emch_id=1532086821\\u003cbr\\u003enonce_str=3DLZ7Og37r8SJDTO\\u003cbr\\u003eopenid=olNvTvq3TVq8QLWA4wRVdVxS9Mi4\\u003cbr\\u003eout_trade_no=WXZFC2019051614461685801\\u003cbr\\u003eresult_code=SUCCESS\\u003cbr\\u003ereturn_code=SUCCESS\\u003cbr\\u003ereturn_msg=OK\\u003cbr\\u003esign=23FB763DCC9A5692029F1B20B88CBE01\\u003cbr\\u003etime_end=20190516144631\\u003cbr\\u003etotal_fee=15\\u003cbr\\u003etrade_state=SUCCESS\\u003cbr\\u003etrade_state_desc=支付成功\\u003cbr\\u003etrade_type=MICROPAY\\u003cbr\\u003etransaction_id=4200000333201905168104579300\\u003cbr\\u003e";
//
//        System.out.println(str2);
//        HashMap<String,String> map=new HashMap<>();
//        while (str2.indexOf("=") > 0) {
//            int i = str2.indexOf("=");
////            System.out.println(str2.substring(0, i));
//            String ksy=str2.substring(0, i);
//            str2 = str2.substring(++i);
//            i = str2.indexOf("\\u003cbr\\u003e");
////            System.out.println(str2.substring(0, i));
//            String value=str2.substring(0, i);
//            str2 = str2.substring(i + 14);
//            map.put(ksy,value);
//        }
//        for (String goo:map.keySet()){
//            System.out.println(goo+"="+map.get(goo));
//        }
//
//        System.out.println(str3.substring(2));
//        System.out.println(getResDateF7());

    }

    public static List<String> getStrings(String s) {

        List<String> strs = new ArrayList<String>();
        Pattern p = Pattern.compile("GraphType\\s*=\\s*\".+\"\\s*");
        Matcher m = p.matcher(s);
        while (m.find()) {
            strs.add(m.group());

        }
        return strs;
    }

    public static String getDa(String date){
        return date=date.substring(0,10)+" 00:00:00:127";
    }

}
